const mongoose = require('mongoose');

const commentSchema = new mongoose.Schema({
    content: {
      type: String,
      required: [true, '评论内容不能为空'],
      trim: true,
      maxlength: [1000, '评论最多1000个字符']
    },
    post: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Post',
      required: [true, '评论必须关联到文章']
    },
    author: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
      required: [true, '评论必须关联到用户']
    },
    parentComment: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Comment'
    },
    status: {
      type: String,
      enum: ['active', 'deleted'],
      default: 'active'
    }
  }, {
    timestamps: true
  });

const Comment = mongoose.model('Comment', commentSchema);
module.exports = Comment;
